package cn.wolfcode.entity;

import lombok.*;

import java.util.List;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-10-31 22:32
 */
//封装根据分页条件查询后页面显示的数据
@Setter
@ToString
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class PageResult<T> {
    private int currentPage;//当前页
    private int pageSize;//每页显示条数
    private int totalCount;//数据的总条数
    private List<T> data;//数据
    private int prevPage;//上一页
    private int nextPage;//下一页
    private int totalPage;//总页数【尾页】

    public PageResult(int currentPage, int pageSize, int totalCount, List<T> data) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.data = data;
        totalPage = totalCount%pageSize==0?totalCount/pageSize:
                totalCount/pageSize+1;
        this.prevPage = currentPage-1>=1?currentPage-1:1;
        this.nextPage = currentPage+1<=totalPage?currentPage+1:totalPage;
    }
}
